package com.wimcorp.magic.dataloader.abilities;

import java.util.Map;
import java.util.Set;

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.user.client.ui.ListBox;
import com.wimcorp.magic.data.AbilityData;
import com.wimcorp.magic.input.AbilityInput;

public class ReturnWidget extends AbilityWidget {

	private ListBox destinationList;

	public ReturnWidget(AbilityInput ability) {
		super(ability);
	}

	protected void initAbilityFields() {
		super.initAbilityFields();
		destinationList = new ListBox();
		addInputSingleLocationList("Destination", destinationList, 0);
	}

	public JSONObject getAbilityConfig() {
		JSONObject config = super.getAbilityConfig();
		config.put("destination", getSelectedItems(destinationList));
		return config;
	}

	public void load(AbilityData abilityData) {
		super.load(abilityData);
		JSONObject config = (JSONObject) JSONParser.parseLenient(abilityData.getConfig());

		loadListBox(destinationList, config.get("destination"));

	}

}
